package GUILayer;

import ControlLayer.*;
import ModelLayer.*;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

public class MainMenuGUI extends JFrame implements ActionListener
{
	private JPanel 		topPanel,
						addressBookPanel,
						dvdCollectionPanel,
						loanPanel;
	
	private JTabbedPane	tabbedPane;
	
	private JScrollPane	addressScrollPane,
						dvdScrollPane,
						loanScrollPane;
	
	private JList		addressList,
						dvdList,
						loanList;
	
	private JButton		newPersonButton,
						showPersonButton,
						editPersonButton,
						deletePersonButton,
						newDvdButton,
						showDvdButton,
						editDvdButton,
						deleteDvdButton,
						newLoanButton,
						showLoanButton,
						editLoanButton,
						deleteLoanButton;
	
	public MainMenuGUI()
	{
		this.setSize(300, 200);
		this.setResizable(true);
		this.setVisible(true);
		
		topPanel = new JPanel();
		topPanel.setLayout(new BorderLayout());
		this.getContentPane().add(topPanel);
		
		createAddressPage();
		createDvdPage();
		createLoanPage();
		
		tabbedPane = new JTabbedPane();
		tabbedPane.addTab("Address Book", addressBookPanel);
		tabbedPane.addTab("DVD Collection", dvdCollectionPanel);
		tabbedPane.addTab("Loans", loanPanel);
		
		topPanel.add(tabbedPane,BorderLayout.CENTER);
	}
	
	private void createAddressPage()
	{
		addressBookPanel = new JPanel();
		addressBookPanel.setLayout(null);
		
		newPersonButton = new JButton("New Person");
		newPersonButton.addActionListener(this);
		
		showPersonButton = new JButton("Show Person");
		showPersonButton.addActionListener(this);
		
		editPersonButton = new JButton("Edit Person");
		editPersonButton.addActionListener(this);
		
		deletePersonButton = new JButton("DeletePerson");
		deletePersonButton.addActionListener(this);
		
		addressList = new JList();//TODO associate with ...
		
		addressScrollPane = new JScrollPane(addressList);
		
		newPersonButton.setBounds(10 , 10, 100, 20);
		showPersonButton.setBounds(10, 30, 100, 20);
		editPersonButton.setBounds(10, 50, 100, 20);
		deletePersonButton.setBounds(10, 70, 100, 20);
		
		addressScrollPane.setBounds(120, 10, 150, 100);
		
		addressBookPanel.add(newPersonButton);
		addressBookPanel.add(showPersonButton);
		addressBookPanel.add(editPersonButton);
		addressBookPanel.add(deletePersonButton);
		addressBookPanel.add(addressScrollPane);
	}
	
	private void createDvdPage()
	{
		dvdCollectionPanel = new JPanel();
		dvdCollectionPanel.setLayout(null);
		
		newDvdButton = new JButton("New DVD");
		newDvdButton.addActionListener(this);
		
		showDvdButton = new JButton("Show DVD");
		showDvdButton.addActionListener(this);
		
		editDvdButton = new JButton("Edit DVD");
		editDvdButton.addActionListener(this);
		
		deleteDvdButton = new JButton("Delete DVD");
		deleteDvdButton.addActionListener(this);
		
		dvdList = new JList();//TODO associate with ...
		
		dvdScrollPane = new JScrollPane(dvdList);
		
		newDvdButton.setBounds(10 , 10, 100, 20);
		showDvdButton.setBounds(10, 30, 100, 20);
		editDvdButton.setBounds(10, 50, 100, 20);
		deleteDvdButton.setBounds(10, 70, 100, 20);
		
		dvdScrollPane.setBounds(120, 10, 150, 100);
		
		dvdCollectionPanel.add(newDvdButton);
		dvdCollectionPanel.add(showDvdButton);
		dvdCollectionPanel.add(editDvdButton);
		dvdCollectionPanel.add(deleteDvdButton);
		dvdCollectionPanel.add(dvdScrollPane);
	}
	
	private void createLoanPage()
	{
		loanPanel = new JPanel();
		loanPanel.setLayout(null);
		
		newLoanButton = new JButton("New Loan");
		newLoanButton.addActionListener(this);
		
		showLoanButton = new JButton("Show Loan");
		showLoanButton.addActionListener(this);
		
		editLoanButton = new JButton("Edit Loan");
		editLoanButton.addActionListener(this);
		
		deleteLoanButton = new JButton("Delete Loan");
		deleteLoanButton.addActionListener(this);
		
		loanList = new JList();//TODO associate with ...
		
		loanScrollPane = new JScrollPane(loanList);
		
		newLoanButton.setBounds(10 , 10, 100, 20);
		showLoanButton.setBounds(10, 30, 100, 20);
		editLoanButton.setBounds(10, 50, 100, 20);
		deleteLoanButton.setBounds(10, 70, 100, 20);
		
		loanScrollPane.setBounds(120, 10, 150, 100);
		
		loanPanel.add(newLoanButton);
		loanPanel.add(showLoanButton);
		loanPanel.add(editLoanButton);
		loanPanel.add(deleteLoanButton);
		loanPanel.add(loanScrollPane);
	}
	
	public static void main(String[] args)
	{
		new MainMenuGUI();
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
	}
}
